using System.Collections.Generic;
using System.Linq;
using Magiq.Support;

namespace Magiq.Databases.SqlServer
{
    public class SqlServerDialect : IDialect
    {
        public virtual string DeleteClauseFor(string tableName, string from)
        {
            return "DELETE " + tableName + " FROM " + from;
        }

        public virtual string UpdateClauseFor(string tableName, Dictionary<string, string> sets, string from)
        {
            return "UPDATE " + tableName + " SET " + sets.Select(x => x.Key + "=" + x.Value).Join(",") + " FROM " + from;
        }

        public virtual string InsertClauseFor(string tableName, Dictionary<string, string> columnValues, string from)
        {
            return "INSERT INTO " + tableName + " (" + columnValues.Keys.Join(",") +
                   ") SELECT " + columnValues.Values.Join(",") +
                   " FROM " + from;
        }
    }
}